package model.quiz
{
	public class MathQuestionVo
	{
		public var numlist:Vector.<Number>;
		
		public var operateList:Vector.<int>; //运算符合 1 加 2 减 3 混合加减
		
		public var answer:Number;
		
		
		public var myanswer:Number;
		
		public var myanswerChoice:String;
		
		//type  1 只有加法 2 只有减法 3 加减都行 size 2 两个数字运算 3 三个数字运算
		public function MathQuestionVo(range:int,type:int,size:int=2)
		{
			var firstNum:Number = Math.round(Math.random() * range);
			
			numlist = new Vector.<Number>();
			operateList = new Vector.<int>();
			
			numlist.push(firstNum);
			
			if(type == 1)//加法
			{
				 var secNum:Number = Math.round(Math.random() * (range - firstNum));
				 numlist.push(secNum);
				 
				 operateList.push(1);
				 
				 answer = firstNum + secNum;
				 if(size > 2)
				 {
					 var thirdNum:Number = Math.round(Math.random() * (range - firstNum -secNum));
					 numlist.push(thirdNum);
					 
					 operateList.push(1);
					 
					 answer += thirdNum;

				 }

			}			
			else if(type == 2)//减法
			{
				var secNum:Number = Math.round(Math.random() * firstNum);
				numlist.push(secNum);
				
				operateList.push(2);
				
				answer = firstNum - secNum;
				if(size > 2)
				{
					var thirdNum:Number = Math.round(Math.random() * (firstNum -secNum));
					numlist.push(thirdNum);
					
					operateList.push(2);
					
					answer -= thirdNum;
					
				}
				
			}
			else if(type == 3)//混合加减法
			{
				if(Math.random() > 0.5) //加法
				{
					var secNum:Number = Math.round(Math.random() * (range - firstNum));
					numlist.push(secNum);
					
					operateList.push(1);
					
					answer = firstNum + secNum;
				}
				else
				{
					secNum = Math.round(Math.random() * (firstNum));
					numlist.push(secNum);
					
					operateList.push(2);
					
					answer = firstNum - secNum;
				}
				
				if(size > 2)
				{
					if(Math.random() > 0.5) //加法
					{
						var thirdNum:Number = Math.round(Math.random() * (range -answer));
						numlist.push(thirdNum);
						
						operateList.push(1);
						
						answer += thirdNum;
					}
					else
					{
						var thirdNum:Number = Math.round(Math.random() * answer);
						numlist.push(thirdNum);
						
						operateList.push(2);
						
						answer -= thirdNum;
					}
					
				}
				
			}
			
		}
		
	}
}